package com.itheima.d6_generics_class;


public class Test {
    public static void main(String[] args) {
        // 目标：掌握泛型类的定义和使用。
        //把MyArrayList改造成可以指定类型存储数据
        MyArrayList list1 = new MyArrayList(); //E 默认就是Object
        list1.add("你好");
        list1.add(100);


        Object o = list1.get(0);
        System.out.println(o);

        //String hi = (String) list1.get(0);
        //String str = (String) list1.get(1);

        MyArrayList<String> list2 = new MyArrayList<>();
        list2.add("Hello");
        //list2.add(100);
        String str = list2.get(0);
        System.out.println("str = " + str);

    }
}


